package com.cbb.springcloud.controller;

import com.cbb.springcloud.common.entity.PaymentEntity;
import com.cbb.springcloud.common.result.Result;
import com.cbb.springcloud.common.result.ResultUtil;
import com.cbb.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 支付 controller
 *
 * @author chaibb
 * @date 2021-07-12 19:39:33
 */
@RestController
@RequestMapping("/api/payment")
@Slf4j
public class PaymentController {


    @Autowired
    private PaymentService paymentService;

    /**
     * 新增
     *
     * @author chaibb
     * @date 2021-07-12 19:52:32
     */
    @PostMapping("/create")
    public Result<String> create(@RequestBody PaymentEntity payment) {
        System.out.println("requestBody = " + payment);
        paymentService.insert(payment);
        System.out.println("result = " + payment);
        return ResultUtil.success();
    }

    /**
     * 根据 id 查看详情
     *
     * @author chaibb
     * @date 2021-07-12 19:53:18
     */
    @GetMapping("/getPaymentById/{id}")
    public Result<PaymentEntity> getPaymentById(@PathVariable Long id) {
        return ResultUtil.success(paymentService.getPaymentById(id));
    }
}
